
#ifndef __fx_reflectionH__
#define __fx_reflectionH__

#include "camera.h"
#include "texture.h"
#include "physics.h"

namespace WtfEngine {

	class PlanarReflection: public Static {
		tDirection mPlane;
		Transformation3D mReflection;

	public:
		typedef struct PlanarReflectionCreationOptions: public Static::tCreationOptions {
			tDirection vPlanarNormal;
		} tCreationOptions;

		PlanarReflection(const tCreationOptions& opts, const WtfGraphics::GraphicsData::tCacheRef& rGfx,
			const PhysicalModel::tCacheRef& rModel);

		virtual void Render();

		static Transformation3D CreateTransform(const tPlane& plane, const tPosition& vIntersection);
		GC_OBJECT(PlanarReflection, GC_ADDEDSIZE_AUTO(Static, PlanarReflection));
	};

	/**
	 * Defines a planar mirror 2D reflection map, generated by the oblique
	 * frustum clipping technique.
	 **/
	class ObliqueFrustumReflection: public virtual IPerspective, public virtual IDynamic, public FBOTexture {
		tPosition	mvPosition, mvReflectedCameraPosition;
		ICamera::tRef mrCamera;
		tPlane		mPlane;
		tVector::tHouseholderMatrix mHouseholderMatrix;

		public:
			ObliqueFrustumReflection(const tPosition& vPosition, const tPlane& plane, const iVector2D& vResolution = iVector2D(256, 256));
			
			ICamera::tRef getCamera() const { return mrCamera; };
			void setCamera(const ICamera::tRef& rCamera);

			virtual void EnterPerspective(const IScreen::tRef& pScreen) const;
			virtual void LeavePerspective() const;

			virtual void Update();

		GC_AUTOSIZE(ObliqueFrustumReflection);
	};
};


#endif
